<template>
	<view class="orderGoods">
		<view class='total' v-if="!split">共{{totalNmu}}件商品</view>
		<view class='total' v-if="split">
			<text>订单包裹{{index + 1}}</text>
			<view class="rig-btn" v-if="status_type === 2">
				<view class="logistics sure" @click="confirmOrder(orderId)">确认收货</view>
				<view v-if="delivery_type === 'express'" class="logistics" @click="logistics(orderId)">查看物流</view>
			</view>
			<view class="rig-btn" v-else-if="status_type === -1">
				<view class="refund">申请退款中</view>
			</view>
			<view class="rig-btn" v-else-if="status_type === -2">
				<view class="refund">已退款</view>
			</view>
			<view class="rig-btn" v-else-if="status_type === 4">
				<view class="done">已完成</view>
			</view>
		</view>

		<view class='goodWrapper'>
			<view class='' v-for="(item,index) in cartInfo" :key="index"
				@click="jumpCon(item.product_id)">
				<!-- 商城商品 -->
				<block v-if="item.productInfo && item.module_type === 1">
					<view class="item acea-row row-between-wrapper">
						<view class='pictrue'>
							<image :src='item.productInfo.attrInfo.image' v-if="item.productInfo.attrInfo"></image>
							<image :src='item.productInfo.image' v-else></image>
						</view>
						<view class='text'>
							<view class='acea-row row-between-wrapper'>
								<view class='name line1' style="width: 425rpx;">{{item.productInfo.store_name}}</view>
								<view class='num'>x {{item.cart_num}}</view>
							</view>
							<view class='attr line1' v-if="item.productInfo.attrInfo">{{item.productInfo.attrInfo.suk}}</view>
							<view class='money font-color' v-if="item.productInfo.attrInfo">￥{{item.productInfo.attrInfo.price}}
							</view>
							<view class='money font-color' v-else>￥{{item.productInfo.price}}</view>
							
							<view class='evaluate' v-if='item.is_reply==0 && (evaluate==3 || evaluate==4)'
								@click.stop="evaluateTap(item.unique,orderId)">评价</view>
							<view class='evaluate' v-else-if="item.is_reply==1 && (evaluate==3 || evaluate==4)">已评价</view>
						</view>
					</view>
				</block>
				<!-- 门店商品 -->
				<block v-if="item.shopProductInfo && item.module_type === 2">
					<view class="item acea-row row-between-wrapper">
						<view class='pictrue'>
							<image :src='item.shopAttrInfo.image' v-if="item.shopAttrInfo"></image>
							<image :src='item.shopProductInfo.image' v-else></image>
						</view>
						<view class='text'>
							<view class='acea-row row-between-wrapper'>
								<view class='name line1' style="width: 425rpx;">{{item.shopProductInfo.store_name}}</view>
								<view class='num'>x {{item.cart_num}}</view>
							</view>
							<view class='attr line1' v-if="item.shopAttrInfo">{{item.shopAttrInfo.suk}}</view>
							<view class='money font-color' v-if="item.shopAttrInfo">￥{{item.shopAttrInfo.price}}
							</view>
							<view class='money font-color' v-else>￥{{item.sum_price}}</view>
							<view class='evaluate' v-if='item.is_reply==0 && (evaluate==3 || evaluate==4)'
								@click.stop="evaluateTap(item.unique,orderId)">评价</view>
							<view class='evaluate' v-else-if="item.is_reply==1 && (evaluate==3 || evaluate==4)">已评价</view>
						</view>
					</view>
				</block>
				<!-- 券包 -->
				<block v-if="item.module_type === 3 || (item.module_type && item.module_type.length > 0)">
					<view class="item acea-row row-between-wrapper">
						<view class='pictrue'>
							<image :src='item.image'></image>
						</view>
						<view class='text'>
							<view class='acea-row row-between-wrapper'>
								<view class='name line1' style="width: 370rpx;">{{item.title}}</view>
								<view class='num'>￥{{item.price}}</view>
							</view>
							<view class='attr line1'>优惠券 x{{ item.couponData.length }}</view>
						</view>
					</view>
				</block>
				<!-- 其他 -->
				<block v-if="item.productInfo && !item.module_type">
					<view class="item acea-row row-between-wrapper">
						<view class='pictrue'>
							<image :src='item.productInfo.attrInfo.image' v-if="item.productInfo.attrInfo"></image>
							<image :src='item.productInfo.image' v-else></image>
						</view>
						<view class='text'>
							<view class='acea-row row-between-wrapper'>
								<view class='name line1' style="width: 425rpx;">{{item.productInfo.store_name}}</view>
								<view class='num'>x {{item.cart_num}}</view>
							</view>
							<view class='attr line1' v-if="item.productInfo.attrInfo">{{item.productInfo.attrInfo.suk}}</view>
							<block v-if="item.productInfo.combination == 1 && item.productInfo.from == 1 && isWeikuan == 1">
								<view class='money font-color'>首付款￥{{item.productInfo.group_adv_price}}</view>
							</block>
							<block v-else>
								<view class='money font-color' v-if="item.productInfo.attrInfo">￥{{item.productInfo.attrInfo.price}}
								</view>
								<view class='money font-color' v-else>￥{{item.productInfo.price}}</view>
							</block>
							<view class='evaluate' v-if='item.is_reply==0 && (evaluate==3 || evaluate==4)'
								@click.stop="evaluateTap(item.unique,orderId)">评价</view>
							<view class='evaluate' v-else-if="item.is_reply==1 && (evaluate==3 || evaluate==4)">已评价</view>
						</view>
					</view>
				</block>
				<!-- 月配商品  v-if="item.productInfo.store_type == 2" -->
				<!-- <view class="submission_time1 acea-row" v-if="item.productInfo && item.productInfo.store_type == 2">
					<view class="pictrue" style="width: 150rpx;"></view>
					<text class="blod">首次配送：</text>
					<text>{{ item.receive_time.days + ' ' + item.receive_time.name}}</text>
				</view> -->
				<!-- 自选日期商品  v-if="item.productInfo.store_type == 3" -->
				<view class="submission_time1 acea-row" v-if="item.productInfo && item.productInfo.store_type == 3 && showTime">
					<view class="pictrue" style="width: 150rpx;"></view>
					<text class="blod">收花日期：</text>
					<text>{{ item.receive_time.days + ' ' + item.receive_time.name}}</text>
				</view>
				<view class="gift_item acea-row row-between-wrapper" v-if="item.gift_product && item.gift_product.length > 0">
					<view class="pictrue" style="width: 150rpx;"></view>
					<view class="acea-row" style="flex: 1;">
						<view class="blod">赠品</view>
						<view class="" style="flex: 1;">
							<view class="acea-row row-between-wrapper" v-for="(itemn,ind) in item.gift_product" :key="ind">
								<text class="line1">{{ itemn.productInfo.store_name }}</text>
								<text>x {{ itemn.cart_num }}</text>
							</view>
						</view>
					</view>
				</view>
				
			</view>
			<view class="more-operation" v-if="split && refund_status === 0" @click="changeOperation">
				{{operationModel?'关闭':'更多操作'}}
			</view>
			<transition name="fade" mode="out-in" v-if="split && operationModel && refund_status === 0">
				<!-- #ifdef MP -->
				<view>
					<view class="more-operation b-top" @click="openSubcribe">
						申请退款
					</view>
				</view>
				<!-- #endif -->
				<!-- #ifndef MP -->
				<navigator hover-class="none" :url="'/pages/users/goods_return/index?orderId='+ orderId"
					class='more-operation b-top'>申请退款
				</navigator>
				<!-- #endif -->
			</transition>
		</view>
	</view>
</template>

<script>
	export default {
		props: {
			goodType: {
				type: Number || String,
				default: 1
			},
			evaluate: {
				type: Number,
				default: 0,
			},
			cartInfo: {
				type: Array,
				default: function() {
					return [];
				}
			},
			orderId: {
				type: String,
				default: '',
			},
			delivery_type: {
				type: String,
				default: '',
			},
			jump: {
				type: Boolean,
				default: false,
			},
			split: {
				type: Boolean,
				default: false,
			},
			index: {
				type: Number,
				default: 0,
			},
			refund_status: {
				type: Number,
				default: 0,
			},
			status_type: {
				type: Number,
				default: 0,
			},
			showTime: {
				type: Boolean,
				default: true
			},
			isWeikuan: {
				type: [String, Number],
				default: 0
			}
		},
		data() {
			return {
				totalNmu: '',
				operationModel: false,
				status: ""
			};
		},
		watch: {
			cartInfo: function(nVal, oVal) {
				let num = 0
				nVal.forEach((item, index) => {
					num += item.cart_num
				})
				this.totalNmu = num == 0 ? 1 : num
			}
		},
		methods: {
			evaluateTap: function(unique, orderId) {
				uni.navigateTo({
					url: "/pages/users/goods_comment_con/index?unique=" + unique + "&uni=" + orderId
				})
			},
			jumpCon: function(id) {
				if(!id) return
				if (this.jump) {
					uni.navigateTo({
						url: `/pages/goods_details/index?id=${id}`
					})
				}
			},
			logistics(order_id) {
				uni.navigateTo({
					url: '/pages/users/goods_logistics/index?orderId=' + order_id
				})
			},
			confirmOrder(orderId) {
				this.$emit('confirmOrder', orderId)
			},
			changeOperation() {
				this.operationModel = !this.operationModel
			},
			openSubcribe() {
				this.$emit('openSubcribe', '/pages/users/goods_return/index?orderId=' + this.orderId)
			},
		}
	}
</script>

<style scoped lang="scss">
	.orderGoods {
		background-color: #fff;
		// margin-top: 12rpx;
		border-radius: 10rpx;
	}
	.submission_time1 {
		width: 100%;
		background-color: #fff;
		padding: 0 30rpx 15rpx;
		font-size: 20rpx;
		.blod {
			font-weight: 700;
		}
	}
	.gift_item {
		width: 100%;
		background-color: #fff;
		padding: 0 30rpx 15rpx;
		font-size: 20rpx;
		.line1 {
			width: 380rpx;
		}
		.blod {
			font-weight: 700;
			margin-right: 10rpx;
		}
	}
	.orderGoods .total {
		display: flex;
		justify-content: space-between;
		align-items: center;
		width: 100%;
		// height: 86rpx;
		padding: 0 30rpx;
		border-bottom: 2rpx solid #f0f0f0;
		font-size: 30rpx;
		color: #282828;
		line-height: 86rpx;
		box-sizing: border-box;

		.rig-btn {
			display: flex;
			align-items: center;

			.refund {
				font-size: 26rpx;
				color: #DD3823;
			}

			.done {
				font-size: 26rpx;
				color: #4193f7;
			}
		}

		.logistics {
			// height: 46rpx;
			line-height: 30rpx;
			color: #999999;
			font-size: 20rpx;
			border: 1px solid;
			border-radius: 30rpx;
			padding: 6rpx 12rpx;
			margin-left: 10rpx;
		}

		.sure {
			color: #e93323;
			border: 1px solid #e93323;
		}
	}

	.more-operation {
		display: flex;
		justify-content: center;
		align-items: center;
		padding: 10rpx 0;
		color: #bbb;
	}

	.b-top {
		margin-left: 30rpx;
		margin-right: 30rpx;
		border-top: 1px solid #f0f0f0
	}

	.fade-enter-active,
	.fade-leave-active {
		transition: all 0.1s;
	}

	.fade-enter,
	.fade-leave-to

	/* .fade-leave-active below version 2.1.8 */
		{
		opacity: 0;
		transform: translateY(-10px);
	}
	.goodWrapper .item {
		border-bottom: 0;
	}
</style>
